<?php
namespace app\service;
use think\facade\Db;
class serviceService{
    //查询服务商数据
    public function serviceList(){
        return Db::name('service')->order('id asc')->paginate(50);
    }
    //查询服务商条数
    public function serviceNumber(){
        return Db::name('service')->select();
    }
    //查询服务商是否已添加
    public function serviceName($name){
        return Db::name('service')->where('name',$name)->find();
    }
    //添加服务商
    public function serviceAdd($data){
        return Db::name('service')->insert($data);
    }
    //查询指定ID服务商信息
    public function serviceId($id){
        return Db::name('service')->where('id',$id)->find();
    }
    //修改指定ID服务商信息
    public function serviceUpdate($data){
		return Db::name('service')->update($data);
    }
    //根据登录账号查询小区信息
    public function communityList($where){
        return Db::name('community')->where($where)->select();
    }
    //查询支付类型
    public function paytypeList(){
        return Db::name('paytype')->select();
    }
    //查询业务类型
    public function cashierList($community_id,$page,$where){
        return Db::name('cashier')->where('community_id','in',$community_id)->where($where)->order('id desc')->paginate(100,false, [
            'page'  =>  $page,
            'query' =>  $where
        ]);
    }
    //查询条数
    public function cashierListNumber($community_id,$where){
        return Db::name('cashier')->where('community_id','in',$community_id)->where($where)->select();
    }
    //根据小区id查询小区名称
    public function communityIdName($community_id){
        return Db::name('community')->where('community_id',$community_id)->value('community_name');
    }
    //添加业务收费
    public function cashierAdd($data){
        return Db::name('cashier')->insert($data);
    }
    //删除业务收费
    public function cashierId($id){
        return Db::name('cashier')->where('id',$id)->find();
    }
}